package com.yesjpt.util;

import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson2.JSONObject;

public class JsonUtil {
	//此类不可实例化
	private JsonUtil() {}
	/*
	 * 返回操作的JSONObject
	 */
	public static JSONObject succ(String message) {
		JSONObject o = new JSONObject();
		o.put("success", true);
		o.put("message", message);
		return o;
	}
	public static JSONObject fail(String message, Object e) {
		JSONObject o = new JSONObject();
		o.put("success", false);
		o.put("message", message + ": " + e);
		return o;
	}

	public static Map<String, String> paramsValueObj2String(Map<String, Object> params) {
		Map<String, String> map = new HashMap<>();
		for (String s : params.keySet()) {
			map.put(s, (String) params.get(s));
		}
		return map;
	}

}
